package com.example.wendao.view.ui.fragment;


import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;

import com.example.wendao.R;
import com.example.wendao.view.utils.DataUtil;
import com.example.wendao.view.widget.TextAndGraphicsView;

/**
 * A simple {@link Fragment} subclass.
 */
public class ShowNewsFragment extends Fragment {
    private ScrollView sv_main;//TextAndGraphicsView的父控件必须是ScrollView
    private String[] mData;//图文数据的列表
    private TextAndGraphicsView mtextAndGraphicsView=null;
    private View view;
    public ShowNewsFragment() {}


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_show_news, container, false);
        parseData();//解析数据
        initView();//初始化ui
        return view;
    }
    private void parseData() {
        //根据分割线来把文字和图片地址存入数组中
        mData = DataUtil.getData().split(DataUtil.SPLIT_TAG);
    }

    private void initView() {
        sv_main = (ScrollView) view.findViewById(R.id.sv_main);
        mtextAndGraphicsView = new TextAndGraphicsView(view.getContext(),mData);

        sv_main.addView(mtextAndGraphicsView);
    }
}
